package leetcode.code2404;

public class Solution {
	public int mostFrequentEven(int[] nums) {
		int[] h = new int[100001];
		int ans = -1, cnt = 0;
		for (int num : nums) {
			if ((num & 1) == 0) {
				h[num] += 1;
				if (h[num] > cnt) {
					cnt = h[num];
					ans = num;
				} else if (h[num] == cnt && num < ans) {
					ans = num;
				}
			}
		}
		return ans;
	}
}
